/*
 * Copyright (c) 2006-2021, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2022-05-17     fanlulin       the first version
 */


#include "led.h"
static rt_thread_t led = RT_NULL;

static void led_entry(void *parameter)
{
    while(1){
        rt_pin_write(LED_PIN1, PIN_HIGH);
        rt_thread_mdelay(500);
        rt_pin_write(LED_PIN1, PIN_LOW);
        rt_thread_mdelay(500);

        rt_pin_write(LED_PIN2, PIN_HIGH);
        rt_thread_mdelay(500);
        rt_pin_write(LED_PIN2, PIN_LOW);
        rt_thread_mdelay(500);

        rt_pin_write(LED_PIN3, PIN_HIGH);
        rt_thread_mdelay(500);
        rt_pin_write(LED_PIN3, PIN_LOW);
        rt_thread_mdelay(500);
    }
}

int led_thread(void){
    led = rt_thread_create("led",
                            led_entry, RT_NULL,
                            THREAD_STACK_SIZE,
                            THREAD_PRIORITY, THREAD_TIMESLICE);
    if (led != RT_NULL){
        rt_thread_startup(led);
        rt_kprintf("led thread start successfully\r\n");
    }

    else{
        rt_kprintf("led thread start failed\r\n");
    }
    return 0;
}


